
// Norm.Database.Jaxer.js
// Philip Weaver philip@philmaker.com

Norm.Database = {
	
	_db : null,
	name : "jaxer.orm",
	
	execute : function(sql, params) {
		
		try {
			if (Norm.debug) {
				Norm.log(sql, params);
			}
			return Jaxer.DB.execute(sql, params || []);
		} catch(e) {
			throw new Error(e.message);
		}
	},
	
	executeAndClose : function(sql, params) {
		
		try {
			if (Norm.debug) {
				Norm.log(sql, params);
			}
			var resultSet = Jaxer.DB.execute(sql, params || []);
			//resultSet.close();
			return resultSet;
		} catch(e) {
			throw new Error(e.message);
		}
	},
	
	close : function() {
		//Norm.Database.getDB().close();
	},
	
	extend : function(src, add) {
		
		if (! add) {
			add = src;
			src = this;
		}
		
		for (var property in add) {
			src[property] = add[property];
		}
		
		return src;
	},
	
	getLastInsertRowId : function() {
		
		var lastInsertRowID = Jaxer.DB.defaultConnections.DEVELOPER.conn.lastInsertRowID;
		lastInsertRowID =  uneval(lastInsertRowID);
		lastInsertRowID =  parseInt(lastInsertRowID);
		return lastInsertRowID;
	}
	
};
